package com.max.mil.fuwu.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.max.mil.common.util.DataPage;
import com.max.mil.fuwu.model.vo.Prod;
import com.max.mil.fuwu.service.ProdService;
import com.max.mil.fuwu.service.impl.ProdServiceImpl;

@Controller
@RequestMapping("/prod")
public class ProdController
{
	
	ProdService prodService = new ProdServiceImpl();
	
	@ResponseBody
	@RequestMapping("/getProdList")
	public JsonRsp getProdList(String ids, String codes, String name, String cateId, Integer pageNo, Integer pageSize) throws Exception 
	{
		JsonRsp jsonRsp = new JsonRsp();
		
		DataPage<Prod> dp = prodService.getProdList(
				ids, codes, name, cateId, 15, pageNo!=null?pageNo:1, pageSize!=null?pageSize:10);
		jsonRsp.setData(dp);
		
		return jsonRsp;
	}
}

class JsonRsp
{
	int ret = 0;
	String msg = "success!";
	Object data = null;
	
	final static JsonRsp SUCCESS = new JsonRsp(0,"success!");
	final static JsonRsp ERROR   = new JsonRsp(0,"error!");
	
	public JsonRsp()
	{
	}
	
	public JsonRsp(int ret, String msg)
	{
		this.ret = ret;
		this.msg = msg;
	}
	
	public int getRet()
	{
		return ret;
	}
	public void setRet(int ret)
	{
		this.ret = ret;
	}
	public String getMsg()
	{
		return msg;
	}
	public void setMsg(String msg)
	{
		this.msg = msg;
	}

	public Object getData()
	{
		return data;
	}

	public void setData(Object data)
	{
		this.data = data;
	}
}
